package com.school;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 宿舍管理系统 - 启动类
 * 
 * @author School
 * @since 2023-10-15
 */
@Slf4j
@SpringBootApplication
@MapperScan("com.school.dao.mybatis")
public class DormitoryManagementApplication {
    
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(DormitoryManagementApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '宿舍管理系统' is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "Druid监控: \thttp://" + ip + ":" + port + path + "/druid\n" +
                "----------------------------------------------------------");
    }
}

